package com.ryzx.jpa.helper.base;

import com.querydsl.core.types.Predicate;
import com.ryzx.common.response.BapException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.util.List;
import java.util.Optional;

public interface BapBaseService<T extends BapBaseEntity,ID> {
    Long count(Predicate t) ;
    List<T> findAll(Predicate spec);
    List<T> findAll(Predicate spec, Sort sort);
    Page<T> findAllToPage(Predicate predicate, Pageable page);
    <E extends BapBaseDTO> Page<T> findAllToPage(E e);
    T save(T t);
    Optional<T> findById(ID id);
    boolean del(T t);
    boolean delById(ID id);
    boolean delAll(Predicate spec);
    boolean delByIds(List<ID> ids) throws BapException;
}
